package gui.newTournamentWindow;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;

import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.WindowConstants;

import core.CustomIcons;
import core.GuiComponentLabels;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class NewTournamentWindow extends javax.swing.JFrame {
	private JLabel tournamentTypeLabel;
	private JLabel tournamentNameLabel;
	private JLabel startDateLabel;
	private JLabel tournamentLeadLabel;
	private JTextField refereeTextBox;
	private JButton closeButton;
	private JButton okButton;
	private JLabel endDateLabel;
	private JTextField endDateTextBox;
	private JTextField tournamentLeadTextBox;
	private JTextField organizerTextBox;
	private JTextField startDateTextBox;
	private JTextField tournamentNameTextBox;
	private JComboBox tournamentTypeDropDown;
	private JLabel refereeLabel;
	private JLabel organizerLabel;
	private JButton currentDateButton;

	private final NewTournamentWindowController controller;
	private static NewTournamentWindow instance = null;

	private NewTournamentWindow() {
		super();
		this.setIconImage(CustomIcons.iconImage);
		this.controller = new NewTournamentWindowController();
		this.initGUI();
	}

	public static NewTournamentWindow getInstance() {
		if (instance == null) {
			instance = new NewTournamentWindow();
			try {
				instance.getController().setTournamentTypesDropDown();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return instance;
	}

	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout(this.getContentPane());
			this.getContentPane().setLayout(thisLayout);
			this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Neues Turnier anlegen");
			{
				this.tournamentTypeLabel = new JLabel();
				this.tournamentTypeLabel.setText(GuiComponentLabels.TOURNAMENT_TYPE);
				this.tournamentTypeLabel.setBackground(new java.awt.Color(209, 209, 209));
			}
			{
				this.tournamentNameLabel = new JLabel();
				this.tournamentNameLabel.setText(GuiComponentLabels.TOURNAMENT_NAME);
				this.tournamentNameLabel.setBackground(new java.awt.Color(209, 209, 209));
			}
			{
				this.startDateLabel = new JLabel();
				this.startDateLabel.setText(GuiComponentLabels.START_DATE);
				this.startDateLabel.setBackground(new java.awt.Color(209, 209, 209));
			}
			{
				this.endDateLabel = new JLabel();
				this.endDateLabel.setText(GuiComponentLabels.END_DATE);
				this.endDateLabel.setBackground(new java.awt.Color(209, 209, 209));
			}
			{
				this.organizerLabel = new JLabel();
				this.organizerLabel.setText(GuiComponentLabels.ORGANIZER);
				this.organizerLabel.setBackground(new java.awt.Color(209, 209, 209));
			}
			{
				this.tournamentLeadLabel = new JLabel();
				this.tournamentLeadLabel.setText(GuiComponentLabels.TOURNAMENT_LEAD);
				this.tournamentLeadLabel.setBackground(new java.awt.Color(209, 209, 209));
			}
			{
				this.refereeLabel = new JLabel();
				this.refereeLabel.setText(GuiComponentLabels.REFEREE);
				this.refereeLabel.setBackground(new java.awt.Color(209, 209, 209));
			}
			{
				this.tournamentTypeDropDown = new JComboBox();
				this.tournamentTypeDropDown.setEditable(true);

				/**
				 * Auto-generated main method to display this JFrame
				 */
			}
			{
				this.currentDateButton = new JButton(CustomIcons.calendar);
				this.currentDateButton.setText("");
				this.currentDateButton.setFocusable(false);
				this.currentDateButton.setSize(57, 57);
				this.currentDateButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						NewTournamentWindow.this.controller.setCurrentDate();
					}
				});
			}
			{
				this.okButton = new JButton();
				this.okButton.setText(GuiComponentLabels.OK_BUTTON);
				this.okButton.setIcon(CustomIcons.ok);
				this.okButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						NewTournamentWindow.this.controller.createNewTournament();
					}
				});
			}
			{
				this.closeButton = new JButton();
				this.closeButton.setText(GuiComponentLabels.CANCEL_BUTTON);
				this.closeButton.setIcon(CustomIcons.delete);
				this.closeButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						NewTournamentWindow.this.controller.performCloseOperation();
					}
				});
			}
			{
				this.tournamentNameTextBox = new JTextField();
			}
			{
				this.startDateTextBox = new JTextField();
			}
			{
				this.endDateTextBox = new JTextField();
			}
			{
				this.organizerTextBox = new JTextField();
			}
			{
				this.tournamentLeadTextBox = new JTextField();
			}
			{
				this.refereeTextBox = new JTextField();
			}
			thisLayout.setVerticalGroup(thisLayout
					.createSequentialGroup()
					.addContainerGap()
					.addGroup(
							thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
									.addComponent(this.tournamentTypeLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.tournamentTypeDropDown, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(
							thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
									.addComponent(this.tournamentNameLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.tournamentNameTextBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(
							thisLayout
									.createParallelGroup()
									.addGroup(
											thisLayout
													.createSequentialGroup()
													.addGroup(
															thisLayout
																	.createParallelGroup(GroupLayout.Alignment.BASELINE)
																	.addComponent(this.startDateLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
																	.addComponent(this.startDateTextBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
																			GroupLayout.PREFERRED_SIZE))
													.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
													.addGroup(
															thisLayout
																	.createParallelGroup(GroupLayout.Alignment.BASELINE)
																	.addComponent(this.endDateLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
																	.addComponent(this.endDateTextBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
																			GroupLayout.PREFERRED_SIZE)))
									.addComponent(this.currentDateButton, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(
							thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
									.addComponent(this.organizerLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.organizerTextBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(
							thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
									.addComponent(this.tournamentLeadLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.tournamentLeadTextBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(
							thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
									.addComponent(this.refereeLabel, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.refereeTextBox, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(
							thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
									.addComponent(this.okButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.closeButton, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addContainerGap(15, 15));
			thisLayout.setHorizontalGroup(thisLayout
					.createSequentialGroup()
					.addContainerGap()
					.addGroup(
							thisLayout.createParallelGroup().addComponent(this.refereeLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.tournamentLeadLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.organizerLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.endDateLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.startDateLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.tournamentNameLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE)
									.addComponent(this.tournamentTypeLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 148, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					.addGroup(
							thisLayout
									.createParallelGroup()
									.addGroup(
											thisLayout.createSequentialGroup().addComponent(this.refereeTextBox, GroupLayout.PREFERRED_SIZE, 383, GroupLayout.PREFERRED_SIZE)
													.addGap(0, 0, Short.MAX_VALUE))
									.addGroup(
											thisLayout.createSequentialGroup().addComponent(this.tournamentLeadTextBox, GroupLayout.PREFERRED_SIZE, 383, GroupLayout.PREFERRED_SIZE)
													.addGap(0, 0, Short.MAX_VALUE))
									.addGroup(
											thisLayout.createSequentialGroup().addComponent(this.organizerTextBox, GroupLayout.PREFERRED_SIZE, 383, GroupLayout.PREFERRED_SIZE)
													.addGap(0, 0, Short.MAX_VALUE))
									.addGroup(
											GroupLayout.Alignment.LEADING,
											thisLayout
													.createSequentialGroup()
													.addGroup(
															thisLayout.createParallelGroup().addComponent(this.endDateTextBox, GroupLayout.Alignment.LEADING, 0, 314, Short.MAX_VALUE)
																	.addComponent(this.startDateTextBox, GroupLayout.Alignment.LEADING, 0, 314, Short.MAX_VALUE))
													.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
													.addComponent(this.currentDateButton, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE))
									.addGroup(
											thisLayout.createSequentialGroup().addComponent(this.tournamentNameTextBox, GroupLayout.PREFERRED_SIZE, 383, GroupLayout.PREFERRED_SIZE)
													.addGap(0, 0, Short.MAX_VALUE))
									.addGroup(
											thisLayout.createSequentialGroup().addComponent(this.tournamentTypeDropDown, GroupLayout.PREFERRED_SIZE, 383, GroupLayout.PREFERRED_SIZE)
													.addGap(0, 0, Short.MAX_VALUE))
									.addGroup(
											GroupLayout.Alignment.LEADING,
											thisLayout.createSequentialGroup().addGap(0, 100, Short.MAX_VALUE).addComponent(this.okButton, GroupLayout.PREFERRED_SIZE, 136, GroupLayout.PREFERRED_SIZE)
													.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
													.addComponent(this.closeButton, GroupLayout.PREFERRED_SIZE, 136, GroupLayout.PREFERRED_SIZE))).addContainerGap());

			this.pack();
			this.setSize(573, 318);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public JComboBox getTournamentTypeDropDown() {
		return this.tournamentTypeDropDown;
	}

	public JLabel getTournamentTypeLabel() {
		return this.tournamentTypeLabel;
	}

	public void setTournamentTypeLabel(JLabel tournamentTypeLabel) {
		this.tournamentTypeLabel = tournamentTypeLabel;
	}

	public JLabel getTournamentNameLabel() {
		return this.tournamentNameLabel;
	}

	public void setTournamentNameLabel(JLabel tournamentNameLabel) {
		this.tournamentNameLabel = tournamentNameLabel;
	}

	public JLabel getStartDateLabel() {
		return this.startDateLabel;
	}

	public void setStartDateLabel(JLabel startDateLabel) {
		this.startDateLabel = startDateLabel;
	}

	public JLabel getTournamentLeadLabel() {
		return this.tournamentLeadLabel;
	}

	public void setTournamentLeadLabel(JLabel tournamentLeadLabel) {
		this.tournamentLeadLabel = tournamentLeadLabel;
	}

	public JTextField getRefereeTextBox() {
		return this.refereeTextBox;
	}

	public void setRefereeTextBox(JTextField refereeTextBox) {
		this.refereeTextBox = refereeTextBox;
	}

	public JLabel getEndDateLabel() {
		return this.endDateLabel;
	}

	public void setEndDateLabel(JLabel endDateLabel) {
		this.endDateLabel = endDateLabel;
	}

	public JTextField getEndDateTextBox() {
		return this.endDateTextBox;
	}

	public void setEndDateTextBox(JTextField endDateTextBox) {
		this.endDateTextBox = endDateTextBox;
	}

	public JTextField getTournamentLeadTextBox() {
		return this.tournamentLeadTextBox;
	}

	public void setTournamentLeadTextBox(JTextField tournamentLeadTextBox) {
		this.tournamentLeadTextBox = tournamentLeadTextBox;
	}

	public JTextField getOrganizerTextBox() {
		return this.organizerTextBox;
	}

	public void setOrganizerTextBox(JTextField organizerTextBox) {
		this.organizerTextBox = organizerTextBox;
	}

	public JTextField getStartDateTextBox() {
		return this.startDateTextBox;
	}

	public void setStartDateTextBox(JTextField startDateTextBox) {
		this.startDateTextBox = startDateTextBox;
	}

	public JTextField getTournamentNameTextBox() {
		return this.tournamentNameTextBox;
	}

	public void setTournamentNameTextBox(JTextField tournamentNameTextBox) {
		this.tournamentNameTextBox = tournamentNameTextBox;
	}

	public JLabel getRefereeLabel() {
		return this.refereeLabel;
	}

	public void setRefereeLabel(JLabel refereeLabel) {
		this.refereeLabel = refereeLabel;
	}

	public JLabel getOrganizerLabel() {
		return this.organizerLabel;
	}

	public void setOrganizerLabel(JLabel organizerLabel) {
		this.organizerLabel = organizerLabel;
	}

	public NewTournamentWindowController getController() {
		return this.controller;
	}
}
